/**
 * 
 */
package front_shop;

import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;

/**
 * @author wx
 *
 */
@SuppressWarnings({ "serial", "unused" })
public class xp extends JDialog implements ActionListener{

	/**
	 * @param args
	 */
	
	xp(	Object z[][],int i,String hykh,String ys,String ss,String zl){
		JScrollPane panel;
		JButton button;
		JTable table;
		JLabel a,b,c,d,e,f,g,h;
		Object t[][]=new Object[i][5];

		for(int j=0;j<i;j++){
				t[j][0]=z[j][1];
				t[j][1]=z[j][4];
				t[j][2]=z[j][5];
				t[j][3]=z[j][6];
				t[j][4]=z[j][7];
		}
		
		a=new JLabel("购物小票");		
		c=new JLabel("商品名称   数量     售价     折扣     金额");
		d=new JLabel("会员卡号：  "+hykh);
		e=new JLabel("应收:   "+ys);
		f=new JLabel("实收:   "+ss);
		g=new JLabel("找零:   "+zl);
		h=new JLabel("欢迎下次光临！！！！！");

		button=new JButton("关闭");
		button.requestFocus();
		panel=new JScrollPane();
		panel.setLayout(null);
		Date nowTime=new Date();
		String time=String.format("%tY-%<tm-%<td", nowTime);
		b=new JLabel(time);

		this.add(panel);
		panel.add(button);
		Object columnname[]={"商品名称","数量","售价","折扣","金额"};
		table=new JTable(t,columnname);
		panel.add(a);
		panel.add(b);
		panel.add(c);
		panel.add(e);
		panel.add(f);
		panel.add(g);
		panel.add(h);
		panel.add(d);


		
		a.setBounds(90,10,60,20);
		c.setBounds(10,30,230,20);
		d.setBounds(10,320,100,20);//ys
		e.setBounds(10,340,100,20);//ys
		f.setBounds(10,360,100,20);
		g.setBounds(10,380,100,20);
		h.setBounds(10,400,180,20);
		panel.add(table);
		table.setBounds(0,50,230,250);
		b.setBounds(10,300,80,20);//time
		table.enable(false);
		button.setBounds(90,420,60,20);
		button.addActionListener(this);
		table.getColumnModel().getColumn(1).setPreferredWidth(30);
		table.doLayout();



		





		table.repaint();
		
	}
	/*public static void main (String args[]){
		Object t[][]= new Object[18][8];
		int i=0;
		String a,b,c,d;
		a=b=c=d="";
		xp frame=new xp(t,i,a,b,c,d);
		frame.setTitle("购物小票 ");
		frame.setBounds(400,100,250,500);
		frame.setVisible(true);
		frame.validate();
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	}
	@Override*/
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		this.dispose();
	}
	


}